function winClose(){$.messager.confirm("提示", "确认关闭当前页面?", function(r){if(r){window.parent.removeCurrSelectTab();}});}
function winReload(){$.messager.confirm("提示", "确认刷新当前页面?", function(r){if(r){window.location.reload()}});}
function alert(msg){$.messager.alert("提示",msg);}	
function show(msg){$.messager.show({showType: 'show',title:"提示",msg:msg,timeout:3000});}	
function confirm(title, msg, fn){$.messager.confirm(title, msg, fn);}
		
		
/*表单参数获取*/
function formParams(id) {
	var params = "";
	var isValid = true;/*是否通过校验*/
	$("#" + id + " :input").each(function(i, inp) {
		if(inp.name!=null && inp.name!=''){
			if (inp.required != null || inp.validType != null) {
				if (!$(inp).validatebox("isValid")) {
					isValid = false;
				}
			}
			params += "&" + inp.name + "=" + encodeURI(inp.value);
		}
	});
	return isValid ? params : null;
}

/*表单提交*/
function formSubmit(form, successFn) {
	var form1 = form.tagName != null ? form : document.getElementById(form);/*如果为元素则直接调用，也可以为id*/
	var url = form1.action;
	var params = formParams(form1.id);/*获取参数*/
	if (params == null) {return false;}/*校验不通过*/
	var dataType = "json";//返回类型
	if (form1.dataType != null && form1.dataType != "") {dataType = form1.dataType;}/*配置了返回类型*/
	$.ajax( {/*开始请求*/
		type: "POST",	url: url,	data: params, dataType: dataType,
		success: successFn,	error: function(e) {e.form = form1;formSubmitError(e);}
	});
}

function formSet(formId, data){
	$("#"+ formId +" :input").each(function(i, n){
		if(n.name!=null && n.name!=''){
			var ns = n.name.split(".");
			var v1 = data[ns[ns.length-1]];
			if(n.tagName=='SELECT'){
				setSelectValue(n,v1);
			}else{
				n.value = data==''? (n.defaultValue==null?"":n.defaultValue) : v1==null?"":v1;
				if(n.formatter!=null){
					n.value = eval(n.formatter).call(this,n.value);
				}
			}
		}
	});
}

/*easyui 自动赋值  未完成*/
function easyuiFormSet(id, data){
	$("#"+id+" input[class^='easyui']").each(function(i,n){
		var ns = n.id.split(".");
		var v1 = data[ns[ns.length-1]];
		//alert(n.id+":"+n.className);
		if(n.className=='easyui-datebox datebox-f combo-f'){
			$(n).datebox("setValue",v1);
		}
	});
}


function setSelectValue(sel,value){
	var ops = sel.options;
	for(var i=0; i<ops.length ;i++){
		if(ops[i].value == value){
			sel.selectedIndex = i;
		}
	}
}

function setSelectText(sel,value){
	var ops = sel.options;
	for(var i=0; i<ops.length ;i++){
		if(ops[i].innerText == value){
			sel.selectedIndex = i;
		}
	}
}

function formGet(formId){
	var obj = new Object();
	$("#"+ formId +" :input").each(function(i, n){
		if(n.name!=null && n.name!=''){
			obj[n.name] = n.value;
		}else if(n.id!=null && n.id!=''){
			obj[n.id] = n.value;
		}
	});
	return obj;
}

/*表单提交发生异常时统一调用函数*/
function formSubmitError(error) {alert("error:"+error.responseText);}

/*校验*/
$.extend($.fn.validatebox.defaults.rules,{number: {validator: function(value, param){return /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); },message: '错误的数字'}}); 
$.extend($.fn.validatebox.defaults.rules,{mobile: {validator: function(value, param){return /^0{0,1}(13[4-9]|15[7-9]|15[0-2]|18[7-8])[0-9]{8}$/.test(value);   },message: '错误的手机号码'}});
$.extend($.fn.validatebox.defaults.rules,{phone: {validator: function(value, param){return /(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/.test(value);}, message: '错误的电话号码'}});  
$.extend($.fn.validatebox.defaults.rules,{ip: { validator: function(value, param){return /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/.test(value);}, message: '错误的IP地址'}});
$.extend($.fn.validatebox.defaults.rules,{integer: {validator: function(value, param){return /^[0-9]*$/.test(value); },message: '错误的数字'}});

//页面加载等待页面
var height = window.screen.height - 250;
var width = window.screen.width;
var leftW = 300;
if (width > 1200) {leftW = 500;} else if (width > 1000) {leftW = 350;} else {leftW = 100;}
leftW = leftW-120;
var _html = "<div id='loading' style='position:absolute;left:0;width:100%;height:"
		+ height
		+ "px;top:0;background:#E0ECFF;opacity:0.8;filter:alpha(opacity=95);'>\ <div style='position:absolute;	cursor1:wait;left:"
		+ leftW
		+ "px;top:200px;width:auto;height:16px;padding:12px 5px 10px 30px;\ background:#fff url(/taxBook/easyui/themes/default/images/pagination_loading.gif) no-repeat scroll 5px 10px;border:2px solid #ccc;color:#000;'>\ 正在加载，请等待...\ </div></div>";
window.onload = function(){ 	
	var _mask = document.getElementById('loading'); 	
	_mask.parentNode.removeChild(_mask);
}	  
document.write(_html);